﻿@*
//------------------------------------------------------------------------------
//  此代码版权声明为全文件覆盖，如有原作者特别声明，会在下方手动补充
//  此代码版权（除特别声明外的代码）归作者本人Diego所有
//  源代码使用协议遵循本仓库的开源协议及附加协议
//  Gitee源代码仓库：https://gitee.com/diego2098/ThingsGateway
//  Github源代码仓库：https://github.com/kimdiego2098/ThingsGateway
//  使用文档：https://diego2098.gitee.io/thingsgateway-docs/
//  QQ群：605534569
//------------------------------------------------------------------------------
*@

@page "/gatewayconfig/driverdebug"
@namespace ThingsGateway.Gateway.Blazor
@using System.Linq.Expressions;
@using BlazorComponent;
@using Furion.DataValidation;
@using Mapster;
@using Masa.Blazor.Presets;
@using System.IO;
@using Masa.Blazor;
@using Microsoft.AspNetCore.Authorization;

@using ThingsGateway.Admin.Blazor;
@using ThingsGateway.Admin.Core;


@attribute [Authorize]
@inherits BaseComponentBase
@inject UserResoures UserResoures

@layout MainLayout

<MRow NoGutters>
    <MCol Md=@(IsShowTreeView?3:0)>
        <MSheet Show=IsShowTreeView Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight}px);border-radius:0px;")>
            <MCardTitle>
                <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_searchName" Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.PluginId)) />
            </MCardTitle>
            <MTreeview Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight+200}px);overflow-y:auto") Dense TItem="DriverPluginCategory"
                       TKey="long" OpenOnClick ActiveChanged=@((async a=>
                       {
                       if(this.SearchModel.PluginId!= a.FirstOrDefault()&&a.Count>0)
                       {
                       this.SearchModel.PluginId= a.FirstOrDefault();
                       await ImportVaiableAsync(this.SearchModel.PluginId);
                       }
                       }) )
                       Items="DriverPlugins" ItemText="r=>r.Name" ItemChildren="r=>r.Children"
                       Search="@_searchName"
                       Activatable ItemKey=@(r=>r.Id)>
                <LabelContent>
                    <span title=@context.Item.Name>
                        @context.Item.Name
                    </span>
                </LabelContent>
                <LabelContent>
                    <span title=@context.Item.Name>
                        @context.Item.Name
                    </span>
                </LabelContent>
            </MTreeview>
        </MSheet>
    </MCol>
    <MCol Md=@(IsShowTreeView?9:12)>
         <MSheet Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight}px);border-radius:0px;")>
             <MSheet Class="mb-3 pa-2  text-h6" Elevation="0" Flat Rounded="false">
                <MRow Align="AlignTypes.Center" Class="mt-1">
                    <MButton Class="mx-1" OnClick=@(async() =>
                             {
                             IsShowTreeView=!IsShowTreeView;
                             }
                             ) Color="primary" Icon>
                        <MIcon>mdi-menu</MIcon>
                    </MButton>
                    <MLabel>
                        @_importRef?.ToString()
                    </MLabel>
                </MRow>
            </MSheet>
            @if (_importRender != null)
            {
                @*<MSheet Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight+50}px);border-radius:0px;")>*@
                    @_importRender
                @*</MSheet>*@
            }
        </MSheet>

    </MCol>

</MRow>


